export default () => {
  const setMouseMoveEvent = (selector?: string) => {
    if (!selector) selector = '#app'
    const el = document.querySelector(selector) as HTMLElement
    el.addEventListener('mousedown', () => {
      // 鼠标按下事件，窗口开始移动
      windowMoveStart()
    })
    el.addEventListener('mouseup', () => {
      // 鼠标抬起事件，窗口移动结束
      windowMoveEnd()
    })
  }

  const windowMoveStart = () => {
    window.api.windowMoveEvent(true)
  }

  const windowMoveEnd = () => {
    window.api.windowMoveEvent(false)
  }

  return {
    setMouseMoveEvent,
  }
}
